#ifndef OBJLOADER_H
#define OBJLOADER_H

#include <vector>
#include <string>
using namespace std;

struct cObjVertex {
	cObjVertex(float f1, float f2, float f3): x(f1), y(f2), z(f3) {}
	float x, y, z;
};

struct cObjNormal {
	cObjNormal(float f1, float f2, float f3): x(f1), y(f2), z(f3) {}
	float x, y, z;
};

struct cObjTexCoord {
	cObjTexCoord(float f1, float f2): u(f1), v(f2) {}
	float u, v;
};

struct cObjMaterial {
	cObjMaterial(string n): name(n), bKdTexture(false), bBumpTexture(false) {}

	string name;
	float Ns;
	float Ka[3];
	float Kd[3];
	float Ks[3];
	float Ni;
	float d;
	int illum;
	bool bKdTexture;
	int map_Kd_texture_ID;
	bool bBumpTexture;
	int map_Bump_texture_ID;
};

struct cObjFace {
	vector<int> vertex;
	vector<int> normal;
	vector<int> texCoord;
	int material;
};

struct cObjObject {
	cObjObject(string n): name(n) {}

	string name;
	vector<cObjFace> face;	
};

struct cObjModel {
	cObjModel() {}
	// 	cObjModel(string n): name(n) {}
	// 
	// 	string name;
	vector<cObjVertex> vertex;
	vector<cObjNormal> normal;
	vector<cObjTexCoord> texCoord;
	vector<cObjObject> object;
};

struct cObjTexture {
	cObjTexture(string n): name(n) {}

	string name;
	int id;
};

struct cObjLoader {
	bool loadObj(string file, vector<cObjMaterial> *mtl, cObjModel *m);
};

struct cMtlLoader {
	bool loadMtl(string file, vector<cObjMaterial> *m, vector<cObjTexture> *t = NULL);
};

extern cObjLoader objLoader;
extern cMtlLoader mtlLoader;

#endif // OBJLOADER_H